<%--
    Document   : login
    Created on : Nov 17, 2012, 14:07:08 PM
    Author     : HoangTN
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <title>Log in</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link href="<%= request.getContextPath()%>/styles/layout.css" rel="stylesheet"
              type="text/css" media="screen" />
    </head>
    <body id="top">
        <div class="wrapper col1">
            <div id="header">
                <div id="logo">
                    <h1><a href="#">BusinessToday</a></h1>
                    <p><strong>Free CSS Website Template</strong></p>
                </div>
                <div id="newsletter">
                    <p>Log in</p>
                    <form name="loginForm" action="<%= request.getContextPath()%>/LoginController"
                          onsubmit="return validateForm()" method="post">
                        <fieldset>
                            <legend>NewsLetter</legend>
                            <input type="text" name="txtUsername" value="Username&hellip;"
                                   onfocus="this.value=(this.value=='Username&hellip;')? '' : this.value ;" />
                            <input type="password" name="txtPassword" value="Password&hellip;"
                                   onfocus="this.value=(this.value=='Password&hellip;')? '' : this.value ;" />
                            <input type="submit" name="btnAction" id="news_go" value="Login" />
                        </fieldset>
                    </form>
                </div>
                <br class="clear" />
            </div>
        </div>

        <div class="wrapper col3">
            <div class="fl_right">
                <img style="right: 100px" src="images/banner.gif" alt="" />
            </div>
            <br class="clear" />
        </div>

        <%@include file="/jsp/common/footer_field.jsp" %>
        <%@include file="/jsp/common/copyright_field.jsp" %>
        <script type="text/javascript">
            function validateForm() {
                var error = [];
                var user = document.forms["loginForm"]["txtUsername"].value;
                if(user==null || user=="") {
                    error[error.length] = "Please input user name";
                }
                var pass = document.forms["loginForm"]["txtPassword"].value;
                if(pass==null || pass=="") {
                    error[error.length] = "Please input password";
                }
                if(error.length > 0){
                    executeError(error);
                    return false;
                }
                return true;
            }
            function executeError(errors) {
                var message = "Warning !!! \n";
                for(var i=0;i<errors.length;i++) {
                    var num = i+1;
                    message += "\n" + num + ". " + errors[i];
                }
                alert(message);

            }
        </script>
    </body>
</html>